home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 4 / Precision Software Applications Silver Collection Volume 4 (1993).iso / stats / chadyn.exe / YCOMB.C < prev    next >
Text File  |  1988-12-09  |  8KB  |  308 lines

  1.  
  2. /*********************************  YCOMB.C  *********************************/
  3. /************************* BASIN COMMANDS AND MENU ***************************/
  4. /********************* (C) 1986,7,8 by JAMES A. YORKE ************************/
  5.  
  6.  
  7. #include "yinclud.h"
  8.  
  9. int     caseBs(CodeName)
  10. char    *CodeName;
  11. {
  12.     int     oldpreiter,
  13.             level0;
  14.     int     AccessBS(), BasinStraddle(), SaddleStraddle();
  15.                 /* needed for use as a pointer */
  16.  
  17.     TEST("bm") {
  18.         BasinMenu();
  19.         return(1);
  20.     }
  21.  
  22.     TEST("sm") {        /* straddle orbit menu */
  23.         StraddleMenu();
  24.         return(1);
  25.     }
  26.  
  27.     TEST("ra") {
  28.         rad_attr = Entervalue(rad_attr, CHECKSET);
  29.         if (SCREEN && printer >= 2)
  30.         {
  31.             PRINT 
  32. "Additional commands for experts:\n");
  33.             PRINT 
  34. "\nCommands RA2 and RA5 allow radii for y2 and y5 to be set independently\n");
  35.         }
  36.         return(1);
  37.     }
  38.     TEST("ra2") {
  39.         ra2 = Entervalue(ra2, SETVALUE);
  40.         return(1);
  41.     }
  42.     TEST("ra5") {
  43.         ra5 = Entervalue(ra5, SETVALUE);
  44.         return(1);
  45.     }
  46.     TEST("sdist") {
  47.         IsClose = Entervalue(IsClose, CHECKSET);
  48.         return(1);
  49.     }
  50.     TEST("triple") {
  51.         PRINT "The distance between ya and yb is tripled          \n");
  52.         triple();
  53.         return(1);
  54.     }
  55.     TEST("bstswitch") {
  56.         if(SCREEN)
  57.             PRINT "set to 1 to randomize midpoint\n");
  58.         BST_switch = (int) Entervalue((double) BST_switch, CHECKSET);
  59.         return(1);
  60.     }
  61.     TEST("mc") {
  62.         MaxChecks = (int) Entervalue((double) MaxChecks, CHECKSET);
  63.         return(1);
  64.     }
  65.     TEST("w") {
  66.         if(level >= PROCESS)
  67.             scr_rowcol(3, 0);
  68.         whenAndWhere();/* tells where the tajectory thru y1 goes and
  69.                    how long it takes to get there; for
  70.                    interrupt W and command W; in YBASINS.C */
  71.         return(1);
  72.     }
  73.     TEST("div") {
  74.         divisions = (int) Entervalue((double) divisions, CHECKSET);
  75.         return(1);
  76.     }
  77.     if(strcmp(CodeName, "sst") == 0
  78.             || strcmp(CodeName, "rsst") == 0
  79.             || strcmp(CodeName, "asst") == 0
  80.             || strcmp(CodeName, "rasst") == 0
  81.             || strcmp(CodeName, "game") == 0
  82.             || strcmp(CodeName, "rgame") == 0) {
  83.  
  84.         if(CodeName[0] == 'r') {
  85.             boot = 1;
  86.         }
  87.     /* the flags are to tell us what type of instruction has been entered;
  88.        game or rgame set the game flag(=YES) while asst or rasst set the
  89.        access flag; these are used in YBASINS.C */
  90.         gameFlag = NO;
  91.         accessFlag = NO;
  92.         if(CodeName[0] == 'a' || CodeName[1] == 'a') {
  93.             accessFlag = YES;
  94.         }
  95.         if(CodeName[0] == 'g' || CodeName[1] == 'g') {
  96.             gameFlag = YES;
  97.         }
  98.  
  99.         level0 = level++;
  100.         oldpreiter = preiter;
  101.         if(preiter == 0) {
  102.             preiter = 1;/* prevents plotting a spurious point */
  103.         }
  104.         initSadStraddle();
  105.                 /* initialize SaddleStraddle(); it can reset
  106.                    "level" */
  107.         if(level == level0)
  108.                 /* this would happen only if we dropped down in
  109.                    level via Interrupt() */
  110.             return(1);
  111.         StraddleIteratee = iteratee;
  112.         ChkTrajIteratee = iteratee;
  113.  
  114.         iteratee = SaddleStraddle;
  115.         level = level0;    /* caseT elevates the level */
  116.         caseT();
  117.         iteratee = StraddleIteratee;/* restores old destination */
  118.         preiter = oldpreiter;
  119.         return(1);
  120.     }
  121.     if(strcmp(CodeName, "bst") == 0
  122.             || strcmp(CodeName, "rbst") == 0) {
  123.         if(CodeName[0] == 'r') {
  124.             boot = 1;
  125.         }
  126.         if(refreshFlag == NO)
  127.             dot = -1;
  128.                 /* this will be set = 0 anyway but it prevents
  129.                    printing out of lyapunov exponents while
  130.                    initial steps are being carried out to see
  131.                    if initial points are well defined */
  132.         level0 = level++;
  133.         oldpreiter = preiter;
  134.         if(preiter == 0) {
  135.             preiter = 1;/* prevents plotting a spurious point */
  136.         }
  137.         initBasStraddle();/* initialize BasinStraddle(); it can reset
  138.                    "level" */
  139.         if(level == level0)
  140.                 /* this would happen only if we dropped down in
  141.                    level via Interrupt() */
  142.             return(1);
  143.         StraddleIteratee = iteratee;
  144.         ChkTrajIteratee = iteratee;
  145.  
  146.         iteratee = BasinStraddle;
  147.                 /* this means Trajectory() will iterate
  148.                    BasinStraddle */
  149.         level = level0;    /* caseT elevates the level */
  150.         caseT();
  151.         iteratee = StraddleIteratee;/* restores old destination */
  152.         preiter = oldpreiter;
  153.         return(1);
  154.     }
  155.     if(strcmp(CodeName, "abst") == 0/* AccessibleBasinStradTraj */
  156.             || strcmp(CodeName, "rabst") == 0) {
  157.         if(CodeName[0] == 'r') {
  158.             boot = 1;
  159.         }
  160.  
  161.         level0 = level++;
  162.         initBasStraddle();/* initialize BasinStraddle(); it can reset
  163.                    "level" */
  164.         if(level == level0)
  165.                 /* this would happen only if we dropped down in
  166.                    level via Interrupt() */
  167.             return(1);
  168.         StraddleIteratee = iteratee;
  169.         ChkTrajIteratee = iteratee;
  170.  
  171.         iteratee = AccessBS;/* this means Trajectory() will iterate
  172.                    AccessBS */
  173.         level = level0;    /* caseT elevates the level */
  174.         caseT();
  175.         iteratee = StraddleIteratee;/* restores old destination */
  176.         return(1);
  177.     }
  178.     if(strcmp(CodeName, "bl") == 0 || strcmp(CodeName, "rbl") == 0) {
  179.         if(CodeName[0] == 'r') {
  180.             boot = 1;
  181.         }
  182.         xpixels = 100;
  183.         ypixels = 100;
  184.  
  185.         BasinBoundary();
  186.         return(1);
  187.     }
  188.     if(strcmp(CodeName, "bmed") == 0 || strcmp(CodeName, "rbmed") == 0) {
  189.         if(CodeName[0] == 'r') {
  190.             boot = 1;
  191.         }
  192.  
  193.         xpixels = 320;
  194.         ypixels = 200;
  195.  
  196.         BasinBoundary();
  197.         return(1);
  198.     }
  199.     if(strcmp(CodeName, "bh") == 0 || strcmp(CodeName, "rbh") == 0) {
  200.         if(CodeName[0] == 'r') {
  201.             boot = 1;
  202.         }
  203.  
  204.         xpixels = 960;
  205.         ypixels = 68 * 8;
  206.  
  207.         BasinBoundary();
  208.         return(1);
  209.     }
  210.     if(strcmp(CodeName, "bmh") == 0 || strcmp(CodeName, "rbmh") == 0) {
  211.         if(CodeName[0] == 'r') {
  212.             boot = 1;
  213.         }
  214.  
  215.         xpixels = 320;
  216.         ypixels = 68 * 4;
  217.  
  218.         BasinBoundary();
  219.         return(1);
  220.     }
  221.  
  222.     if (strncmp(CodeName,"bega",20)==0 || strncmp(CodeName,"rbega",20)==0)
  223.     {
  224.         if (CodeName[0] == 'r')
  225.         {
  226.             boot = 1;
  227.         }
  228.  
  229.         xpixels = 640;
  230.         ypixels = 360;
  231.  
  232.         BasinBoundary();
  233.         return(1);
  234.     }
  235.     if (strncmp(CodeName,"bvga",20)==0 || strncmp(CodeName,"rbvga",20)==0)
  236.     {
  237.         if (CodeName[0] == 'r')
  238.         {
  239.             boot = 1;
  240.         }
  241.  
  242.         xpixels = 640;
  243.         ypixels = 480;
  244.  
  245.         BasinBoundary();
  246.         return(1);
  247.     }
  248.     return(0);
  249. }
  250.  
  251. BasinMenu() {
  252.     if(level == SETPARAM)
  253.         scr_clr();    /* in desmets pcio.a */
  254.     scr_rowcol(0, 0);
  255.  
  256.     PRINT
  257.         "                 BASIN OF ATTRACTION MENU \n\n");
  258.     PRINT
  259.         "The following routine is implicit in all Basin and Straddle calculations. \n"
  260.         );
  261.     PRINT
  262.         " W:  checks Where the trajectory through y1 goes and When it gets there;\n");
  263.     PRINT
  264.         "     whether it comes within RA of y2...y7 or diverges within MC iterates\n"
  265.         );
  266.     PRINT
  267.         "     \"diverges\" means goes more than SD diameters from the screen\n");
  268.  
  269.     PRINT
  270.         " MC: the Maximum number of Checks per Initial point; (now %d)\n"
  271.         ,MaxChecks);
  272.     PRINT
  273.         " RA: minimum acceptable Radius of Attraction for storage vecs; now=%lf\n\n"
  274.         ,rad_attr);
  275.  
  276.     PRINT
  277.         "BASIN PLOTS: each grid point is plotted if its trajectory comes within RA of"
  278.         );
  279.     PRINT
  280.         "\n       y2,y3, or y4 before y5,y6,or y7 or if it diverges\n");
  281.     PRINT
  282.         "       OR is plotted IF the trajectory diverges AND y2[%d] is not set)\n"
  283.         ,zeroth);
  284.     PRINT
  285.         "   Vectors y2...y7 can be set using interrupt m while plotting\n\n");
  286.     PRINT
  287.         "   BASIN WARNING: start with BL; even BL is slow(>10 min for maps on an XT)"
  288.         );
  289.     PRINT
  290.         "\n BL:   to compute basin in Low resolution 100X100 grid\n");
  291.     PRINT
  292.         " BMED: to compute basin in Medium resolution 320X200 grid\n");
  293.     PRINT
  294.         " BH:   to compute basin in High resolution 960X544 grid\n");
  295.  
  296. /*    PRINT
  297. "Program checks dist. of y[] from storage vectors every %d iterate(s)    \n\n"
  298. ,its_per_plot);
  299. */
  300.     PRINT
  301.         " RBL,RBM, and RBH work like BL,BM, and BH but are added to previous picture\n"
  302.         );
  303.     PRINT
  304.         " Enter *BM and possibly *SM for help and YM for setting y's\n");
  305. }
  306.  
  307.  
  308.